package cate.game.play.skill.passive.hero;

import cate.game.play.config.PlayCfgArgs;
import cate.game.play.proce.action.ctx.ActionCtx;
import cate.game.play.skill.FighterCD;
import cate.game.play.skill.passive.common.立即复活PH;

/**
 * 死亡时触发【再临】效果，立即复活(无视禁止复活)并回复自身25%最大生命值，同时提升30%魔法伤害，冷却4回合
 */
public class 女巫禁术PH extends 立即复活PH {

	private double 恢复系数;

	private int 附加buff;

	private int 冷却回合;

	//恢复系数=2500&附加buff=？？&冷却回合=4
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		恢复系数 = args.getWDouble("恢复系数", 0d);
		附加buff = args.getInt("附加buff", 0);
		冷却回合 = args.getInt("冷却回合", 0);
	}

	private int lastRound;

	@Override
	protected double healValue() {
		return skill.owner.attr.total().hpTotal() * 恢复系数;
	}

	@Override
	protected boolean allowResurrect(ActionCtx action) {
		return !FighterCD.inCD(lastRound, 冷却回合, action.getRound().index);
	}

	@Override
	protected boolean ignNoRebirth() {
		return true;
	}

	@Override
	protected void onSuccess(ActionCtx action) {
		lastRound = action.getRound().index;
		skill.owner.buff.tryAddByTid(action, 附加buff);
	}
}
